﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lan.Onvif
{
    public class Library_o
    {
        //根据不同平台加载不同dll路径
        public static bool LoadPath(string folder)
        {
            try
            {
                //库文件路径
                string libPath = System.IO.Path.Combine(Environment.CurrentDirectory, folder);

                //根据软件运行模式设置库文件的路径
                if (Environment.Is64BitProcess)
                {
                    libPath = System.IO.Path.Combine(libPath, "X64");
                }
                else
                {
                    libPath = System.IO.Path.Combine(libPath, "X86");
                }
                //获取当前环境变量Path的值
                var path = Environment.GetEnvironmentVariable("Path");
                //添加库路径到环境变量中
                path += (";" + libPath + ";");
                //设置环境变量
                Environment.SetEnvironmentVariable("Path", path);

                // LogProc.Log.Debug("添加了环境变量" + libPath);

                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
    }
}
